package com.imonsoft.sqm.dao.basedata;

import com.imonsoft.common.httpModel.DataGrid;
import com.imonsoft.common.httpModel.Pager;
import com.imonsoft.sqm.pojo.basedata.Part;
import com.imonsoft.sqm.pojo.basedata.PartExample;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@SuppressWarnings("deprecation")
@Repository("partDAO")
public class PartDAOImpl extends SqlMapClientDaoSupport implements PartDAO {

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public PartDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int countPartByExample(PartExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"ts_part.ibatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int deletePartByExample(PartExample example) {
		int rows = getSqlMapClientTemplate().delete(
				"ts_part.ibatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int deletePartByPrimaryKey(Long id) {
		Part key = new Part();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete(
				"ts_part.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public Long insertPart(Part record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"ts_part.ibatorgenerated_insert", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public Long insertPartSelective(Part record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"ts_part.ibatorgenerated_insertSelective", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	@SuppressWarnings("unchecked")
	public List<Part> selectPartByExample(PartExample example) {
		List<Part> list = getSqlMapClientTemplate().queryForList(
				"ts_part.ibatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public Part selectPartByPrimaryKey(Long id) {
		Part key = new Part();
		key.setId(id);
		Part record = (Part) getSqlMapClientTemplate().queryForObject(
				"ts_part.ibatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int updatePartByExampleSelective(Part record, PartExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"ts_part.ibatorgenerated_updateByExampleSelective", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int updatePartByExample(Part record, PartExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"ts_part.ibatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int updatePartByPrimaryKeySelective(Part record) {
		int rows = getSqlMapClientTemplate().update(
				"ts_part.ibatorgenerated_updateByPrimaryKeySelective", record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	public int updatePartByPrimaryKey(Part record) {
		int rows = getSqlMapClientTemplate().update(
				"ts_part.ibatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table ts_part
	 * @ibatorgenerated  Wed May 29 16:43:16 CST 2013
	 */
	private static class UpdateByExampleParms extends PartExample {
		private Object record;

		public UpdateByExampleParms(Object record, PartExample example) {
			super(example);
			this.record = record;
		}

		@SuppressWarnings("unused")
		public Object getRecord() {
			return record;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
    public DataGrid<Part> getDataGrid(PartExample example, Pager pager) {
        if (example == null) {
            example = new PartExample();
        }
        int total =countPartByExample(example);
        List<Part> rows = getSqlMapClientTemplate().queryForList("ts_part.ibatorgenerated_selectByExample", example, pager.getSkipResults(), pager.getRows());
        DataGrid<Part> dataGrid = new DataGrid<Part>(total, rows);
        return dataGrid;
    }
}